package stocks;

import java.util.ArrayList;

/**
 * the stock exchange, shares are listed here
 * @author Mike
 */

public class StockExchange {
    private static StockExchange instance = null;
    /**
     * a list of all shares
     */
    public ArrayList<Share> shares;

    /**
     * constructor is private due to singleton pattern
     */
    private StockExchange() {
        shares = new ArrayList<Share>();
        //add some shares
        Share share = new Share("IBM",5.2f,10);
        shares.add(share);
        share = new Share("Cisco",7.8f,12);
        shares.add(share);
        share = new Share("Microsoft",0.6f,20);
        shares.add(share);
    }
    /**
     * returns the instance of the stock exchange
     * @return the instance of the stock exchange
     */
    public static StockExchange getInstance () {
        if (instance == null) {
            instance = new StockExchange();
        }
        return instance;
    }
}

